package com.one.customer;

import com.one.constant.RabbitMQConstant;
import com.one.util.RedisUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * Created on 2022-01-03.
 * <p>
 * Author: zhukang
 * <p>
 * Description: 直连模式消费者
 */
@Slf4j
@Component
@RabbitListener(queues = RabbitMQConstant.RABBITMQ_DIRECT_QUEUE_KH91)
public class RabbitMQDirectConsumer {

    @Autowired
    private RedisUtils redisUtils;
    /**
     * @author : zhukang
     * @date : 2022-01-03
     * @return :
     * @description : 从队列消费消息，进行业务处理
     */
    @RabbitHandler
    public void consumeDirectMsgFromQueue(List<Object> userRegistration){
        log.info("###### 从队列：{}，消费消息：{} ######", RabbitMQConstant.RABBITMQ_DIRECT_QUEUE_KH91, userRegistration);

        // TODO 解析消息，进行业务处理......
        userRegistration.forEach(uid ->{
            redisUtils.set(uid.toString(),"您预约的活动将在十分钟后开始");
        });
    }

}
